/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author corneliugosa
 */
@Entity
@Table(name = "homework")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Homework.findAll", query = "SELECT h FROM Homework h")})
public class Homework implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "title")
    private String title;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idHomework")
    private List<ToDoHomework> toDoHomeworkList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idHomework")
    private List<HomeworkToClass> homeworkToClassList;
    @JoinColumn(name = "id_class", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Class idClass;
    @JoinColumn(name = "id_subject_matter", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private SubjectMatter idSubjectMatter;
    @JoinColumn(name = "id_proffessor", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Person idProffessor;

    public Homework() {
    }

    public Homework(Integer id) {
        this.id = id;
    }

    public Homework(Integer id, String title, String description) {
        this.id = id;
        this.title = title;
        this.description = description;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<ToDoHomework> getToDoHomeworkList() {
        return toDoHomeworkList;
    }

    public void setToDoHomeworkList(List<ToDoHomework> toDoHomeworkList) {
        this.toDoHomeworkList = toDoHomeworkList;
    }

    @XmlTransient
    public List<HomeworkToClass> getHomeworkToClassList() {
        return homeworkToClassList;
    }

    public void setHomeworkToClassList(List<HomeworkToClass> homeworkToClassList) {
        this.homeworkToClassList = homeworkToClassList;
    }

    public Class getIdClass() {
        return idClass;
    }

    public void setIdClass(Class idClass) {
        this.idClass = idClass;
    }

    public SubjectMatter getIdSubjectMatter() {
        return idSubjectMatter;
    }

    public void setIdSubjectMatter(SubjectMatter idSubjectMatter) {
        this.idSubjectMatter = idSubjectMatter;
    }

    public Person getIdProffessor() {
        return idProffessor;
    }

    public void setIdProffessor(Person idProffessor) {
        this.idProffessor = idProffessor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Homework)) {
            return false;
        }
        Homework other = (Homework) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Homework[ id=" + id + " ]";
    }
    
}
